package com.medical.server.drug.controller;

import java.util.Arrays;
import java.util.Map;

import com.laozj.common.utils.PageUtils;
import com.laozj.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.medical.server.drug.entity.DruglistEntity;
import com.medical.server.drug.service.DruglistService;



/**
 * 
 *
 * @author laozj
 * @email laozj@medical.com
 * @date 2024-09-01 15:41:31
 */
@RestController
@RequestMapping("drug/druglist")
public class DruglistController {
    @Autowired
    private DruglistService druglistService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = druglistService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{druglistId}")
    public R info(@PathVariable("druglistId") Long druglistId){
		DruglistEntity druglist = druglistService.getById(druglistId);

        return R.ok().put("druglist", druglist);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody DruglistEntity druglist){
		druglistService.save(druglist);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody DruglistEntity druglist){
		druglistService.updateById(druglist);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] druglistIds){
		druglistService.removeByIds(Arrays.asList(druglistIds));

        return R.ok();
    }

}
